home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / MCC_BetterBalance / Developer / C / Examples / BetterBalance-Demo.c next >
C/C++ Source or Header  |  1998-06-08  |  5KB  |  201 lines

  1.  
  2. #include <exec/types.h>
  3. #if defined __MAXON__ || defined __STORM__
  4. #include <pragma/exec_lib.h>
  5. #else
  6. #include <proto/exec.h>
  7. #endif
  8. #include <exec/libraries.h>
  9. #if defined __MAXON__ || defined __STORM__
  10. #include <pragma/muimaster_lib.h>
  11. #else
  12. #include <proto/muimaster.h>
  13. #endif
  14. #include <libraries/mui.h>
  15. #if defined __MAXON__ || defined __STORM__
  16. #include <pragma/intuition_lib.h>
  17. #else
  18. #include <proto/intuition.h>
  19. #endif
  20. #include <intuition/classusr.h>
  21. #if defined __MAXON__ || defined __STORM__
  22. #include <pragma/dos_lib.h>
  23. #else
  24. #include <proto/dos.h>
  25. #endif
  26. #include <dos/dos.h>
  27. #include <workbench/workbench.h>
  28. #include <workbench/startup.h>
  29. #include <clib/alib_protos.h>
  30. #include <stdio.h>
  31. #include <string.h>
  32. #include <stdlib.h>
  33. #if defined __MAXON__ || defined __STORM__
  34. #include <wbstartup.h>
  35. #endif
  36.  
  37. #include <mui/BetterBalance_mcc.h>
  38.  
  39.  
  40. Object         *apMain        = NULL;
  41. Object         *  wiMain;
  42. Object         *    btSave;
  43.  
  44. struct Library *MUIMasterBase = NULL;
  45.  
  46.  
  47. int main(void)
  48. {
  49.   int ret = RETURN_FAIL;
  50.  
  51.   if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME, MUIMASTER_VMIN)))
  52.     goto bye;
  53.  
  54.  
  55.   if (!(apMain = ApplicationObject,
  56.     MUIA_Application_Title,       "BetterBalance-Demo",
  57.     MUIA_Application_Version,     "$VER: BetterBalance-Demo 1.0 (8.6.98) © by Maik \"bZ!\" Schreiber",
  58.     MUIA_Application_Copyright,   "Copyright © 08-Jun-1998 by Maik Schreiber <bZ@iq-computing.de>",
  59.     MUIA_Application_Author,      "Maik Schreiber <bZ@iq-computing.de>",
  60.     MUIA_Application_Description, "Demonstrates BetterBalance.mcc's features",
  61.     MUIA_Application_Base,        "BETTERBALANCEDEMO",
  62.  
  63.     SubWindow, wiMain = WindowObject,
  64.       MUIA_Window_Title, "BetterBalance-Demo 1.0",
  65.       MUIA_Window_Width, MUIV_Window_Width_Visible(75),
  66.       MUIA_Window_Height, MUIV_Window_Height_Visible(75),
  67.       WindowContents, VGroup,
  68.         Child, TextObject,
  69.           MUIA_Text_Contents, "\n\033cPlease visit \033bThe IQ Computing Web Site \033nat \033bwww.IQ-Computing.de\n",
  70.         End,
  71.         Child, HGroup,
  72.           Child, RectangleObject,
  73.             TextFrame,
  74.           End,
  75.           Child, BetterBalanceObject,
  76.             MUIA_ObjectID, 1,
  77.           End,
  78.           Child, RectangleObject,
  79.             TextFrame,
  80.           End,
  81.           Child, BetterBalanceObject,
  82.             MUIA_ObjectID, 2,
  83.           End,
  84.           Child, RectangleObject,
  85.             TextFrame,
  86.           End,
  87.           Child, BetterBalanceObject,
  88.             MUIA_ObjectID, 3,
  89.           End,
  90.           Child, RectangleObject,
  91.             TextFrame,
  92.           End,
  93.         End,
  94.         Child, BetterBalanceObject,
  95.           MUIA_ObjectID, 4,
  96.         End,
  97.         Child, HGroup,
  98.           Child, RectangleObject,
  99.             TextFrame,
  100.           End,
  101.           Child, BetterBalanceObject,
  102.             MUIA_ObjectID, 5,
  103.           End,
  104.           Child, RectangleObject,
  105.             TextFrame,
  106.           End,
  107.           Child, BetterBalanceObject,
  108.             MUIA_ObjectID, 6,
  109.           End,
  110.           Child, RectangleObject,
  111.             TextFrame,
  112.           End,
  113.           Child, BetterBalanceObject,
  114.             MUIA_ObjectID, 7,
  115.           End,
  116.           Child, RectangleObject,
  117.             TextFrame,
  118.           End,
  119.         End,
  120.         Child, BetterBalanceObject,
  121.           MUIA_ObjectID, 8,
  122.         End,
  123.         Child, HGroup,
  124.           Child, RectangleObject,
  125.             TextFrame,
  126.           End,
  127.           Child, BetterBalanceObject,
  128.             MUIA_ObjectID, 9,
  129.           End,
  130.           Child, RectangleObject,
  131.             TextFrame,
  132.           End,
  133.           Child, BetterBalanceObject,
  134.             MUIA_ObjectID, 10,
  135.           End,
  136.           Child, RectangleObject,
  137.             TextFrame,
  138.           End,
  139.           Child, BetterBalanceObject,
  140.             MUIA_ObjectID, 11,
  141.           End,
  142.           Child, RectangleObject,
  143.             TextFrame,
  144.           End,
  145.         End,
  146.         Child, MUI_MakeObject(MUIO_HBar, 10),
  147.         Child, btSave = SimpleButton("Save balance settings to ENV:"),
  148.       End,
  149.     End,
  150.  
  151.   End))
  152.     goto bye;
  153.  
  154.   /* load all BetterBalance positions into application
  155.      (this should be done before opening any window) */
  156.   DoMethod(apMain, MUIM_Application_Load, MUIV_Application_Load_ENV);
  157.  
  158.   /* btSave lets the user save the balance positions into ENV:
  159.      (NOTE: If you also want to save to ENVARC:, you have to use
  160.      MUIM_Application_Save with MUIV_Application_Save_ENVARC, too!)
  161.   */
  162.   DoMethod(btSave, MUIM_Notify, MUIA_Pressed, FALSE, apMain, 2, MUIM_Application_Save, MUIV_Application_Save_ENV);
  163.  
  164.   DoMethod(wiMain, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, apMain, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  165.  
  166.   {
  167.     ULONG open;
  168.  
  169.     set(wiMain, MUIA_Window_Open, TRUE);
  170.     get(wiMain, MUIA_Window_Open, &open);
  171.     if (!open)
  172.       goto bye;
  173.   }
  174.  
  175.   {
  176.     ULONG sigs = 0;
  177.  
  178.     while (DoMethod(apMain, MUIM_Application_NewInput, &sigs) != MUIV_Application_ReturnID_Quit)
  179.     {
  180.       if (sigs)
  181.       {
  182.         sigs = Wait(sigs | SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F);
  183.         if (sigs & SIGBREAKF_CTRL_C)
  184.           break;
  185.         if (sigs & SIGBREAKF_CTRL_F)
  186.           set(apMain, MUIA_Application_Iconified, FALSE);
  187.         else if (sigs & SIGBREAKF_CTRL_E)
  188.           set(apMain, MUIA_Application_Iconified, TRUE);
  189.       }
  190.     }
  191.   }
  192.  
  193.   ret = RETURN_OK;
  194.  
  195.   bye:
  196.   if (apMain)        MUI_DisposeObject(apMain);
  197.   if (MUIMasterBase) CloseLibrary(MUIMasterBase);
  198.   exit(ret);
  199. }
  200.  
  201.